<template>
  <div>
    <van-row class="a">
      <van-col span="4"></van-col>
      <van-col span="4">小说管理平台</van-col>
      <van-col span="4"></van-col>
      <van-col span="4"></van-col>
      <van-col span="4" style="align-content: center">
        <span v-if="this.users_id !==null || this.admin_id!== null">
          <button @click="quit" style="border: none;background-color: #2f54eb;height: 40px">退出登录</button>
        </span>
        <span v-else>
          <button @click="to" style="border: none;background-color: #2f54eb;height: 40px">请登录</button>
        </span>
      </van-col>
      <van-col span="4" style="align-content: center">
        <span v-if="this.users_id">{{this.users_name}}</span>
        <span v-else-if="this.admin_id">{{this.admin_name}}</span>
        <span v-else> </span>
      </van-col>
    </van-row>
    <br>
    <van-row>
      <van-col span="5" class="a" align="center">
        <router-link :to="{path:'/job_add_present'}" style="color: white">添加礼品</router-link>
      </van-col>
      <van-col span="5" offset="1" class="a" align="center">
        <router-link :to="{path:'/job_add_hour'}" style="color: white">发布小说</router-link>
      </van-col>
      <van-col span="5" offset="1" class="a" align="center">
        <router-link :to="{path:'/job_audit'}" style="color: white">小说审核</router-link>
      </van-col>
      <van-col span="5" offset="1" class="a" align="center">
        <router-link :to="{path:'/job_convert'}" style="color: white">兑换礼品</router-link>
      </van-col>
    </van-row>
  </div>
</template>

<script>
export default {
name: "job_index",
  data(){
    return{
      admin_id:localStorage.getItem('admin_id'),
      users_id:localStorage.getItem('users_id'),
      admin_name:localStorage.getItem('admin_name'),
      users_name:localStorage.getItem('users_name'),
    }
  },
  methods:{
    quit(){
      if(localStorage.getItem('users_id')){
        // alert('11')
        localStorage.removeItem('users_id')
        localStorage.removeItem('users_name')
      }else if(localStorage.getItem('admin_id')){
        // alert('22')
        localStorage.removeItem('admin_id')
        localStorage.removeItem('admin_name')
      }
    },
    to(){
      this.$router.push('/job_login')
    }
  },
  mounted() {
    // alert(localStorage.getItem('users_id'))
    // alert(localStorage.getItem('users_name'))
    // alert(localStorage.getItem('admin_id'))
    // alert(localStorage.getItem('admin_name'))
  }
}
</script>

<style scoped>
.a{
  background-color: #2f54eb;
  height: 50px;
  line-height: 50px;
  color: white;
  /*align-content: center;*/
}
</style>